fix(sandbox): track PTY state per SSH channel to fix terminal resize#687
Merged
johntmyers merged 1 commit intomainfrom Mar 30, 2026
Merged
fix(sandbox): track PTY state per SSH channel to fix terminal resize#687johntmyers merged 1 commit intomainfrom
johntmyers merged 1 commit intomainfrom
Conversation
3 tasks
Replace flat pty_master/input_sender/pty_request fields in SshHandler with a HashMap<ChannelId, ChannelState> so each channel tracks its own PTY resources independently. This fixes window_change_request resizing the wrong PTY when multiple channels are open simultaneously. Also fixes ioctl UB in set_winsize (pass &winsize not winsize by value) and adds warn! logging for unknown channels across all handlers. Resolves #543
666bdfa to
c0fe697
Compare
drew
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #573. Reimplemented cleanly on a fresh branch with review feedback addressed.
pty_master/input_sender/pty_requestfields inSshHandlerwithHashMap<ChannelId, ChannelState>so each channel tracks its own PTY resources independentlyset_winsizeto pass&winsizetoioctl, correcting undefined behavior on aarch64warn!logging for unknown channels across all handlers (window_change_request,data,channel_eof) for debuggabilitychannel_closehandler to clean up per-channel state and prevent FD leaksRelated Issue
Resolves #543
Changes
crates/openshell-sandbox/src/ssh.rsChannelStatestruct; migrate per-channel fields intoHashMap<ChannelId, ChannelState>; update all handlers to look up channel state by ID; fix ioctl UB; add warn! logging for unknown channelsImprovements over #573
cargo fmtclean — no formatting violations (CI-blocking issue in fix(sandbox): track PTY state per SSH channel to fix terminal resize #573)window_change_request,data, andchannel_eofnow all logwarn!on unknown channels, matching the error-returning pattern inpty_request/subsystem_request/start_shellchannel_closedocumented — comment explains it subsumeschannel_eoffor cleanupTesting
set_winsize_applies_to_correct_pty— verifies two PTYs can be independently resized using real PTYs viaopenptychannel_state_independent_input_senders— verifies data routing and EOF isolation between channelscargo test -p openshell-sandbox)Checklist
mise run pre-commitpasses (license check failure is pre-existing inarchitecture/plans/)